<?php
/**
 * Eka Framework 0.3.0
 *
 * @copyright Copyright (c) 2008 Alexey Yu. Chuprina <656b61@gmail.com> (http://php-eka.googlecode.com)
 * @license http://www.opensource.org/licenses/mit-license.php MIT License
 *
 * @version $Id$
 */

/**
 * Eka_Config
 *
 * @package Config
 */
class Eka_Config
{
	protected $data = array();
	
	public function __construct(array $data = null)
	{
		if ($data) {
			$this->data = $data;
		}
	}
	
	public function get($key)
	{
		$data =& $this->data;
		foreach (explode('.', $key) as $key) {
			if (!isset($data[$key])) {
				return null;
			}
			$data =& $data[$key];
		}
		return $data;
	}
	
	public function set($key, $value)
	{
		$data =& $this->data;
		foreach (explode('.', $key) as $key) {
			if (!isset($data[$key])) {
				$data[$key] = array();
			}
			$data =& $data[$key];
		}
		$data = $value;
	}
}